package crm.view.setting.addremovelist;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import crm.model.teacherPC.Manager;
import crm.model.teacherPC.bannedList.BannInterface;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AddBannDialog extends JDialog implements ActionListener {
	private JPanel jPanel1;
	private JButton jButton1;
	private JButton jButton2;
	private JPanel jPanel4;
	private JTextArea jTextArea1;
	private JLabel jLabel2;
	private JPanel jPanel3;
	private JTextField jTextField1;
	private JLabel jLabel1;
	private JPanel jPanel2;

	private final Manager manager;
	private final BannInterface bann;
	EnabledListModel listModel;
	public AddBannDialog(Manager manager, BannInterface bann, EnabledListModel listModel, JFrame owner){
		super(owner, true);
		this.manager=manager;
		this.bann=bann;
		this.listModel = listModel;
		initGUI();
		setLocationRelativeTo(null);
		setVisible(true);
	}

	private void initGUI() {
		try {
			{
				jPanel1 = new JPanel();
				BorderLayout jPanel1Layout = new BorderLayout();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(jPanel1Layout);
				{
					jPanel2 = new JPanel(new GridLayout(2,1));
					jPanel1.add(jPanel2, BorderLayout.NORTH);
					{
						jLabel1 = new JLabel();
						jPanel2.add(jLabel1);
						jLabel1.setText("Name: ");

					}
					{
						jTextField1 = new JTextField();
						jPanel2.add(jTextField1);
						jTextField1.setText("");
						jTextField1.setBounds(229, 133, 41, 23);
					}
				}
			}
			{
				jPanel4 = new JPanel();
				getContentPane().add(jPanel4, BorderLayout.SOUTH);
				{
					jButton1 = new JButton();
					jPanel4.add(jButton1);
					jButton1.setText("OK");
					jButton1.addActionListener(this);
				}
				{
					jButton2 = new JButton();
					jPanel4.add(jButton2);
					jButton2.setText("Abbrechen");
					jButton2.addActionListener(this);
				}
			}
			{
				this.setSize(322, 109);
				
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}


	public void actionPerformed(ActionEvent ev) {
		String cmd = ev.getActionCommand();
		if (cmd.equals("OK")){
			bann.addBann(jTextField1.getText());
			listModel.fireItemAddListener(listModel.getSize()+1);
			dispose();
			
		}else if(cmd.equals("Abbrechen")){
			dispose();
		}

	}
}
